@extends('public.admin.layout') 
@section('header')
<h2>小说管理</h2>
@endsection
 
@section('content')
<div class="row">
    <div class="col-sm-12">
    <button type="button" class="btn  btn-primary btn-sm" onclick="window.location='{{route('admin.novel.create')}}'">
                    新增
            </button>
        <table id="example2" class="table table-bordered table-hover dataTable" role="grid" >
            <thead>
                <tr role="row">
                   
                    <th><input type="checkbox" value="" class="fancy"  id="selectAll" onClick="selectAllCheckBox('product',this.checked)"/>ID</th>
											<th>小说名称</th>
											<th>所属分类</th>
											<th>小说作者</th>
											<th>最后更新时间</th>
											<th>小说状态</th>
											<th>添加</th>
											<th>查看</th>
											<th>操作</th>
                </tr>
            </thead>
            <tbody>
                @foreach($list as $novel)
                <tr role="row" class="data-row">
            
                        <td><input type="checkbox" id="{{$novel->novel_id}}" class="fancy"/>{{$novel->id}}
                        </td>
                        <td>{{$novel->novelname}}</td>
                        <td>{{$novel->category->classname}}</td>
                        <td>{{$novel->novelauthor}}</td>
                        <td>{{$novel->update_time}}</td>
                        <td>
                            @if ($novel->novelstate===0)
                            连载中
                     
                            @else
                            已完本 
                            
                            @endif
                            </td>

                        <td>
                            <a class="btn btn-small  btn-primary"
                               href="{{route('admin.vol.create',['id'=>$novel->id])}}">分卷</a>
                            <a class="btn btn-mini   btn-primary"
                               href="{{route('admin.content.create',['id'=>$novel->id])}}">内容</a>
                        </td>

                        <td><a class="btn btn-small  btn-primary"
                               href="{{route('admin.novel.vols',['id'=>$novel->id])}}">分卷</a>
                            <a class="btn btn-mini   btn-primary"
                               href="{{route('admin.content',['id'=>$novel->id])}}">内容</a>
                        </td>

                        <td><a class="btn btn-small  btn-primary"
                               href="{{route('admin.novel.edit',['id'=>$novel->id])}}">修改</a>
                               <button type="button" class="btn btn-warning btn-sm ml5" data-toggle="modal" data-target="#deleteModal">
                                    删除
                            </button>
                            <button type="button" class="btn btn-warning btn-sm ml5" data-toggle="modal" data-target="#digModal">
                                    推荐
                            </button>
                            </td>
                </tr>
                @endforeach

            </tbody>
        </table>
        
        {{$list->links()}}
    </div>
</div>
@if (isset($novel))
@component('public.modal') @slot('modalId') deleteModal @endslot
@slot('modalTitle') 删除小说 @endslot @slot('actionUrl') {{route('admin.novel.delete',['id'=>$novel->id])}} @endslot 
    @component('public.message')
        确定要删除该小说吗？ 
    @endcomponent 
@endcomponent 
@component('public.modal') @slot('modalId') digModal @endslot
@slot('modalTitle') 推荐小说 @endslot @slot('actionUrl') {{route('admin.novel.dig',['id'=>$novel->id])}} @endslot 
    @component('public.message')
        确定要推荐该小说吗？ 
    @endcomponent 
@endcomponent 
@endif
 
@endsection

@section('script')
<script>
    $('#editModal').on('show.bs.modal',function(event){
              var button=$(event.relatedTarget)
              var id=button.data('id')
              var row=button.closest('.data-row')
              var name=row.children('.classname').text()
              $('#classname').val(name)
              $('#classpy').val(row.children('.classpy').text())
         
          })

</script>
@endsection